﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Medical.Business;
using System.IO;
using System.Text;

/// <summary>
/// 获取疾病分类
/// </summary>
public partial class control_SortMenu : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            InitData();
        }
    }

    /// <summary>
    /// 加载数据
    /// </summary>
    protected void InitData()
    {
        StringBuilder sbHtml = new StringBuilder();
        DataTable dt = Common.GetDiseaseSort();
        DataRow[] drList = dt.Select("ParentID=0");
        string strUrlName = string.Empty;
        for (int i = 0; i < drList.Length; i++)
        {
            strUrlName = drList[i]["PageUrlName"].ToString();
            sbHtml.Append("<div class=\"menuitem\">");
            sbHtml.Append("<h2><a href=\"/" + drList[i]["PageUrlName"].ToString() + "/\" target=\"_blank\" title=\"" + drList[i]["Name"].ToString() + "\">" + Server.HtmlEncode(drList[i]["Name"].ToString()) + "</a></h2>");
            if (i < 6)
            {
                sbHtml.Append("<div class=\"subitem\">");
                DataRow[] drSubList = dt.Select("ParentID=" + drList[i]["ID"].ToString());
                for (int j = 0; j < drSubList.Length; j++)
                {
                    sbHtml.Append("<a href=\"/" + strUrlName + "/" + drSubList[j]["PageUrlName"].ToString() + "/\" title=\"" + drSubList[j]["Name"].ToString() + "\" target=\"_blank\">" + Server.HtmlEncode(drSubList[j]["Name"].ToString()) + "</a>");
                    if (i < 5)
                    {
                        if (j % 2 == 0)
                        {
                            sbHtml.Append("<span>|</span>");
                        }
                        else
                        {
                            sbHtml.Append("<br/>");
                        }
                        if (j == 3)
                            break;
                    }
                    else
                    {
                        sbHtml.Append("<br/>");
                    }
                }
                sbHtml.Append("</div>");
            }
            
                sbHtml.Append("</div>");
        }
        sortmenu.InnerHtml = sbHtml.ToString();
    }
}